/*MyPhotoIndex Free Photo Organizer <www.myphotoindex.com>
  Copyright (C) <2006-2009>  <Asaf Yarkoni asaf@yarkoni.net>

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.*/
using System;
using System.Collections.Generic;
using System.Text;
using MyPhotoIndex.Interfaces;
using System.IO;
using System.Drawing;
using MyPhotoIndex.Interfaces.Imaging;
using MyPhotoIndex.Interfaces.ImageFormatProviders;

namespace MyPhotoIndex.Plugins.ImageFormatProviders
{
    public class FormatProviderImageData : IImageMetaData
    {
        DateTime m_dateTaken;
        DateTime m_dateDigitized;
        string m_fileName;
        string m_fileExtention;
        Size m_imageSize;
        Size m_thumbnailSize;
        string m_imageDescription;
        IImageFormatProvider m_provider;
        bool m_isEncrypted;
        float m_focalLength;
        CameraFlashStatus m_flashStatus;
        ImageLightSource m_lightSource;
        CameraMeteringMode m_meteringMode;
        int m_exposureCompensation;
        int m_isoSpeed;
        CameraExposureProgram m_exposureProgram;
        String m_exposureTime;
        float m_aperture;
        String m_oftwareUsed;
        String m_cameraModel;
        String m_cameraMaker;
        DateTime m_lastModified;
        private float m_brightness;
        private byte[] m_thumbnail;
        private List<string> m_keywords = new List<string>();
        private string m_sourceLabel;

        public float Brightness
        {
            get { return m_brightness; }
            set { m_brightness = value; }
        }

        public string SourceLabel
        {
            get { return m_sourceLabel; }
            set { m_sourceLabel = value; }
        }

        #region IImageData Members

        public event EventHandler ImageDataChangedEvent;

        public void InvokeChangedEvent()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public int Id
        {
            get
            {
                throw new Exception("The method or operation is not implemented.");
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public object SyncLock
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public string ImportBatchNumber
        {
            get
            {
                throw new Exception("The method or operation is not implemented.");
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public DateTime DateTaken
        {
            get
            {
                return m_dateTaken;
            }
            set
            {
                m_dateTaken = value;
            }
        }

        public DateTime DateDigitized
        {
            get
            {
                return m_dateDigitized;
            }
            set
            {
                m_dateDigitized = value;
            }
        }

        public string FileName
        {
            get
            {
                return m_fileName;
            }
            set
            {
                m_fileName = value;
                m_fileExtention = Path.GetExtension(m_fileName).Replace(".", String.Empty);
                m_provider = ImageFormatProviders.Default[m_fileExtention];
                IEncryptedFormatProvider ep = m_provider as IEncryptedFormatProvider;
                if (ep != null)
                {
                    m_isEncrypted = true;
                }
                else
                {
                    m_isEncrypted = false;
                }
            }
        }

        public string FileExtention
        {
            get { return m_fileExtention; }
        }

        public int ImageHeight
        {
            get
            {
                return m_imageSize.Height;
            }
            set
            {
                m_imageSize.Height = value;
            }
        }

        public int ImageWidth
        {
            get
            {
                return m_imageSize.Width;
            }
            set
            {
                m_imageSize.Width = value;
            }
        }

        public string ImageDescription
        {
            get
            {
                return m_imageDescription;
            }
            set
            {
                m_imageDescription = value;
            }
        }

        public List<int> Tags
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        public int Rating
        {
            get
            {
                throw new Exception("The method or operation is not implemented.");
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public bool IsVideo
        {
            get
            {
                return m_provider.IsVideo;
            }
        }

        public bool CanRotate
        {
            get
            {
                return m_provider.CanRotate;
            }
        }

        public bool Encrypted
        {
            get { return m_isEncrypted; }
        }

        public DateTime LastModifiedDateTime
        {
            get
            {
                return m_lastModified;
            }
            set
            {
                m_lastModified = value;
            }
        }

        #endregion


        #region IImageData Members

        public string CameraMaker
        {
            get { return m_cameraMaker; }
            set { m_cameraMaker = value; }
        }

        public string CameraModel
        {
            get { return m_cameraModel; }
            set { m_cameraModel = value; }
        }

        public string SoftwareUsed
        {
            get { return m_oftwareUsed; }
            set { m_oftwareUsed = value; }
        }

        public float Aperture
        {
            get { return m_aperture; }
            set { m_aperture = value; }
        }

        public String ExposureTime
        {
            get { return m_exposureTime; }
            set { m_exposureTime = value; }
        }

        public CameraExposureProgram ExposureProgram
        {
            get { return m_exposureProgram; }
            set { m_exposureProgram = value; }
        }

        public int IsoSpeed
        {
            get { return m_isoSpeed; }
            set { m_isoSpeed = value; }
        }

        public int ExposureCompensation
        {
            get { return m_exposureCompensation; }
            set { m_exposureCompensation = value; }
        }

        public CameraMeteringMode MeteringMode
        {
            get { return m_meteringMode; }
            set { m_meteringMode = value; }
        }

        public ImageLightSource LightSource
        {
            get { return m_lightSource; }
            set { m_lightSource = value; }
        }

        public CameraFlashStatus FlashStatus
        {
            get { return m_flashStatus; }
            set { m_flashStatus = value; }
        }

        public float FocalLength
        {
            get { return m_focalLength; }
            set { m_focalLength = value; }
        }

        #endregion

        #region IImageMetaData Members


        public float MaxAperture
        {
            get
            {
                throw new Exception("The method or operation is not implemented.");
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public ImageResolutionUnit ResolutionUnit
        {
            get
            {
                throw new Exception("The method or operation is not implemented.");
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        byte[] IImageMetaData.Thumbnail
        {
            get
            {
                return m_thumbnail;
            }
            set
            {
                m_thumbnail = value;
            }
        }

        public int ThumbnailHeight
        {
            get
            {
                return m_thumbnailSize.Height;
            }
            set
            {
                m_thumbnailSize.Height = value; ;
            }
        }

        public int ThumbnailWidth
        {
            get
            {
                return m_thumbnailSize.Width;
            }
            set
            {
                m_thumbnailSize.Width = value;
            }
        }

        public int XResolution
        {
            get
            {
                throw new Exception("The method or operation is not implemented.");
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public int YResolution
        {
            get
            {
                throw new Exception("The method or operation is not implemented.");
            }
            set
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }

        public List<string> Keywords
        {
            get
            {
                return m_keywords;
            }
            set
            {
                m_keywords = value;
            }
        }

        #endregion
    }
}
